package com.liyy.platform.other.mytest;
import java.io.*;
public class TestIOStream {

	public static void main(String[] args)  {
		InputStream in =null;
		Reader rd =null;
		OutputStream out =null;
		Writer wt =null;
		try{
		in =new FileInputStream("E:/testin.txt");
		rd =new BufferedReader(new InputStreamReader(in,"GBK"));//带缓冲区的以字符（将以字节读取先转换为以字符方式读取）为单位读取文件内容
		out =new FileOutputStream("E:/testin111.txt");
		wt =new BufferedWriter(new OutputStreamWriter(out));//带缓冲区的以字符（将以字节读取先转换为以字符方式读取）为单位向文件写入内容
		}catch (FileNotFoundException e){
			System.out.print("系统找不到指定文件");
		}catch (UnsupportedEncodingException e){
			System.out.print("不支持字符编码");
		}
		int b;
		try {
		while ((b=rd.read())!=-1){
			System.out.print((char)b);
			wt.write(b);
		}
		wt.flush();// 刷新该流的缓冲
		wt.close();
		}catch(IOException e){
			System.out.print("文件读取错误！");
		}
	}

}
